
import 'package:demo202112/utils/common_appbar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/// @Author wywinstonwy
/// @Date 2022/2/14 8:34 上午
/// @Description:

class HomeCustomPage extends StatelessWidget {
  const HomeCustomPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(appBar: getAppBar("自定义UI"),body: CustomHome(),);
  }
}

class CustomHome extends Widget{
  @override
  Element createElement() {
    return HomeView(this);
  }

}

class HomeView extends ComponentElement{
  HomeView(Widget widget) : super(widget);
  String text ='123456789';
  @override
  Widget build() {
    Color primary = Theme.of(this).primaryColor;
    return GestureDetector(
      child: Center(child: TextButton(onPressed: (){
        var t = text.split("")..shuffle();
        text = t.join();
        markNeedsBuild();//点击后将该Element标记为dirty，Element将会rebuild。
      }, child: Text(text,style: TextStyle(color: primary),)),),
    );
  }

}